package temp;

/**
 * @Description: 坦克类
 * @CreateTime: 2024-01-25  14:55
 * @Author: JAMILA
 * @Version: 1.0
 */

public class Tank {
    private int x;//横坐标
    private int y;//纵坐标
    private int direct = 0;//方向：0-上 1-右 2-下 3-左
    private int speed = 1;//坦克移动速度
    private boolean isLive=true;//坦克存活状态

    public Tank(int x, int y, int direct, int speed) {
        this.x = x;
        this.y = y;
        this.direct = direct;
        this.speed = speed;
    }

    public boolean isLive() {
        return isLive;
    }

    public void setLive(boolean live) {
        isLive = live;
    }

    //坦克移动方法
    public void moveUp() {
        //限制坦克不能超过上边界
        if (y>=speed){
            y -= speed;
        }
    }

    public void moveRight() {
        //限制坦克不能超过右边界
        if (1000-x-60>=speed){
            x += speed;
        }
    }

    public void moveDown() {
        //限制坦克不能超过下边界
        if (750-y-60>=speed){
            y += speed;
        }
    }

    public void moveLeft() {
        //限制坦克不能超过左边界
        if (x>=speed){
            x -= speed;
        }
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDirect() {
        return direct;
    }

    public void setDirect(int direct) {
        this.direct = direct;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
}
